clear
est clear



	import delimited "$input/CAGDP9__ALL_AREAS_2017_2022.csv"
		encode description, g(desc)
		destring geofips, g(fips) i(`"""') force
	
	keep if desc==14|desc==11|desc==27

	rename v11 gdp2019
	keep fips gdp2019 desc
	
	
	destring gdp2019, replace force
	
	reshape wide gdp2019,i(fips) j(desc)
	
	g gdp2019_mConRea= gdp201927-gdp201911 -gdp201914
	
	keep fips gdp2019_mConRea
	
	rename fips from_geoid 
		
		
	save "$input/bea_gdp_2019_mConRea.dta", replace
		
	clear 
	
	use "$input/full_geoid_pair_panel.dta"
	
	bysort state_fips: egen max=max(storm)
		drop if max!=1

	replace migration=migration/(tot_pop/100000)
	
			
	
	duplicates drop from_geoid move_year, force
	
	drop gdp2019
	cap drop _merge
	
	merge m:1 from_geoid using 	"$input/bea_gdp_2019_mConRea.dta", nogen
	
	collapse (sum) storm ,by(from_geoid gdp)
	
		
		
		egen mean_storm=mean(storm)
		egen sd_storm=sd(storm)
		egen mean_gdp=mean(gdp)
		egen sd_gdp=sd(gdp)
		g z_storm=(storm-mean_storm)/sd_storm
		g z_gdp=(gdp-mean_gdp)/sd_gdp
		
		g ln_gdp=ln(gdp)
		
		twoway (scatter storm ln_gdp ,m(C) mc(forest_green%10)) ///
						(lfit storm ln_gdp , lc(gs4) lp(dash) ///
						yti("Total storms", size(large)) xtitle("ln(2019 GDP w/o Construction" "or Real Estate)", size(large)) xlab(, nogrid labsize(vlarge)) ylabel(,nogrid labsize(vlarge)) ysize(12) xsize(12) legend(off))	
						
		graph export "$figures/fig_si5.png", as(png) replace
